import { CALL_HISTORY_METHOD } from "./push";

function routerMiddleware(history) {
    return function(middlewareAPI) {
        return function(next) {
            return function(action) {
                if(action.type === CALL_HISTORY_METHOD){
                    const {payload:{method,patch}} = action;
                    history[method](patch);
                }else{//别的动作处理不了 调用下一个dispatch 或者原生的dispatch
                    next(action)
                }
            }
        }
    }
}

export default routerMiddleware;